/*
   Copyright (c) [2023] [魔凤啸天]
   [MFUI] is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2. 
   You may obtain a copy of Mulan PSL v2 at:
            http://license.coscl.org.cn/MulanPSL2 
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
   See the Mulan PSL v2 for more details.  
*/
#pragma once
#include "core.hpp"

namespace MFUI{
	class TextureRect:public CacheNode{
		protected:
		~TextureRect()override;
		SDL_Texture* texture;
		SDL_Rect src;
		Uint8 alpha;
		public:
		//texture仅引用 非空 自行管理内存
		TextureRect(SDL_Texture* texture,Uint8 alpha=255);
		//texture仅引用 非空 自行管理内存
		TextureRect(SDL_Texture* texture,SDL_Rect& src,Uint8 alpha=255);
		void draw(Renderer* r,bool updatecache)override;
		//texture仅引用 非空 自行管理内存
		void settexture(SDL_Texture* texture);
		//texture仅引用 非空 自行管理内存
		void settexture(SDL_Texture* texture,SDL_Rect& src);
		SDL_Texture* gettexture()const;
		void setsrc(SDL_Rect& src);
		const SDL_Rect& getsrc()const;
		void setalpha(Uint8 a);
		Uint8 getalpha()const;
	};
}